﻿using System;
using ExText4SmallBasic;
using Microsoft.SmallBasic.Library;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ExText4SmallBasic.TestProject
{
    [TestClass()]
    public class TextTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod()]
        public void LeftTest1()
        {
            var actual = Text.Left("My name is mike.", 4);
            Assert.AreEqual("My n", (string)actual);
        }

        [TestMethod()]
        public void LeftTest2()
        {
            var actual = Text.Left("My name is mike.", 0);
            Assert.AreEqual("", (string)actual);
        }

        [TestMethod()]
        public void LeftTest3()
        {
            var actual = Text.Left("My name is mike.", 999);
            Assert.AreEqual("My name is mike.", (string)actual);
        }

        [TestMethod(), ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void LeftTest4()
        {
            Text.Left("My name is mike.", -1);
        }

        [TestMethod()]
        public void RightTest1()
        {
            var actual = Text.Right("My name is mike.", 4);
            Assert.AreEqual("ike.", (string)actual);
        }

        [TestMethod()]
        public void RightTest2()
        {
            var actual = Text.Right("My name is mike.", 0);
            Assert.AreEqual("", (string)actual);
        }

        [TestMethod()]
        public void RightTest3()
        {
            var actual = Text.Right("My name is mike.", 999);
            Assert.AreEqual("My name is mike.", (string)actual);
        }

        [TestMethod(), ExpectedException(typeof(ArgumentOutOfRangeException))]
        public void RightTest4()
        {
            Text.Right("My name is mike.", -1);
        }

        [TestMethod()]
        public void LenTest1()
        {
            var actual = Text.Len("My name is Mike.");
            Assert.AreEqual(16, (int)actual);
        }

        [TestMethod()]
        public void LenTest2()
        {
            var actual = Text.Len("");
            Assert.AreEqual(0, (int)actual);
        }

        [TestMethod()]
        public void MidTest1()
        {
            var actual = Text.Mid("My name is Mike.", 9, 2);
            Assert.AreEqual("is", (string)actual);
        }

        [TestMethod()]
        public void MidTest2()
        {
            var actual = Text.Mid("My name is Mike.", 9, 0);
            Assert.AreEqual("", (string)actual);
        }
    }
}
